{$CLEO .qa}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP 

script_name "GNGFST"

const
    Speed_anim = 29@
    Improved_Gangs_Spawn = 28@
end

0087: Speed_anim = 0@ // (float)
0085: Improved_Gangs_Spawn = 1@ // (int)

While true
wait 0 
    if
        887A:   not gang_war_in_progress
    then
        if Improved_Gangs_Spawn == 1
        then 0A8C: write_memory 0x445466 size 4 value 400.0 virtual_protect 0
        end
        0A93: terminate_this_custom_script
    end
    
    if Improved_Gangs_Spawn == 1
    then 0A8C: write_memory 0x445466 size 4 value 100.0 virtual_protect 0
    end
    
        31@ = 0
        while 0EA7: get_any_char_no_save_recursive 31@ progress_to 31@ char_to 0@
            089F: get_actor 0@ pedtype_to 1@
            if and
                80DF:   not actor 0@ driving
                1@ >= 7 //  7, 8, 9, 10, 11, 12, 13, 14
                1@ <= 14
                not 1@ == 8
                is_char_script_controlled 0@
            then

                if
                    Improved_Gangs_Spawn == 1
                then
                    if and
                        not locate_char_distance_to_char 0@ char $PLAYER_ACTOR radius 120.0
                        82CB:   not actor 0@ bounding_sphere_visible
                    then
                        0D4E: 1@ = read_struct 0x96ABBC offset 0x0 size 4 // +_ZN9CGangWars25CoorsOfPlayerAtStartOfWarE CVector <?>  - X
                        0D4E: 2@ = read_struct 0x96ABBC offset 0x4 size 4 // Y
                        0D4E: 3@ = read_struct 0x96ABBC offset 0x8 size 4 // Z
                        08F1: get_zone_at 1@ 2@ 3@ nameB_to 4@s // 8-byte string
                        if
                                0583:   player $PLAYER_CHAR in_zone 4@s
                        then
                            0209: 4@ = random_int_in_ranges 1 5
                            if 4@ == 1
                            then 04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 0.0 -80.0 0.0
                            end
                            if 4@ == 2
                            then 04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 0.0 80.0 0.0
                            end
                            if 4@ == 3
                            then 04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 80.0 0.0 0.0
                            end
                            if 4@ == 4
                            then 04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset -80.0 0.0 0.0
                            end
                            02C0: store_to 1@ 2@ 3@ ped_path_coords_closest_to 1@ 2@ 3@
                            0A8D: 4@  = read_memory 0x96AB64 size 1 virtual_protect 0 //  mov     eax, ds:_ZN9CGangWars5StateE ; CGangWars::State
                            if and
                                not 4@ == 0
                                not locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 60.0
                                locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 100.0
                            then
                                0208: 4@ = random_float_in_ranges -1.5 1.5
                                005B: 1@ += 4@  // (float)
                                0208: 4@ = random_float_in_ranges -1.5 1.5
                                005B: 2@ += 4@  // (float)
                                00A1: put_actor 0@ at 1@ 2@ 3@
                                0E24: fix_char 0@ ground 1 brightness 1 and_fade_in 0
                            end
                        end
                    end
                end

                
                
                //  
                0EFF: get_char_simplest_active_task 0@ id_to 1@ pointer_to 3@
                if and
                    0EE4: locate_char_distance_to_char 0@ char $PLAYER_ACTOR radius 10.0
                    0019:   TIMERB > 2000
                    0A29:   player $PLAYER_CHAR climbing
                then
                    if or
                        1@ == 900 // walk, run to point
                        1@ == 1019 // fight without firegun, 1020 firegun
                        1@ == 1020 // fight without firegun, 1020 firegun
                        0E46: is_char_using_gun 0@
                    then
                        if or
                            0611:   actor $PLAYER_ACTOR performing_animation "CLIMB_Stand"
                            0611:   actor $PLAYER_ACTOR performing_animation "CLIMB_jump_B"
                        then
                            04C4: store_coords_to 4@ 5@ 6@ from_actor $PLAYER_ACTOR with_offset 0.0 -1.0 -1.0
                            0172: 1@ = actor $PLAYER_ACTOR Z_angle
                            0615: define_AS_pack_begin 3@
                            05D3: AS_actor -1 goto_point 4@ 5@ 6@ mode 7 time -1 ms // versionA
                            05D4: AS_actor -1 rotate_angle 1@
                            078F: AS_actor -1 climb 1
                            0616: define_AS_pack_end 3@
                            0618: assign_actor 0@ to_AS_pack 3@
                            061B: remove_references_to_AS_pack 3@
                            0006: TIMERB = 0
                        end
                    end
                end

                //    
                0EFF: get_char_simplest_active_task 0@ id_to 1@ pointer_to 3@
                if and
                    0019:   TIMERA > 2000
                    not 1@ == 210 // simple jump
                    not 1@ == 254 // simple climb
                    0EE4: locate_char_distance_to_char 0@ char $PLAYER_ACTOR radius 50.0
                then
                    if or
                        1@ == 900 // walk, run to point
                        1@ == 1019 // fight without firegun, 1020 firegun
                        1@ == 1020 // fight without firegun, 1020 firegun
                    then
                        04C4: store_coords_to 4@ 5@ 6@ from_actor 0@ with_offset 0.0 0.4 -0.2 // solid
                        04C4: store_coords_to 7@ 8@ 9@ from_actor 0@ with_offset 0.0 0.7 1.0 // solid
                        04C4: store_coords_to 10@ 11@ 12@ from_actor 0@ with_offset 0.0 0.4 2.0 // NOT solid
                        04C4: store_coords_to 13@ 14@ 15@ from_actor 0@ with_offset 0.0 0.7 4.0 // NOT solid
                        0A96: 16@ = ped $player_actor struct
                        get_label_pointer 17@ = label @Buffer // 128
                        if and
                            0D3A: get_collision_between_points 4@ 5@ 6@ and 7@ 8@ 9@ flags 1 1 0 1 0 0 0 0 ignore_entity 16@ store_point_to 4@ 5@ 6@ entity_to 18@ colpoint_data_to 17@
                            not get_collision_between_points 10@ 11@ 12@ and 13@ 14@ 15@ flags 1 1 0 1 0 0 0 0 ignore_entity 16@ store_point_to 10@ 11@ 12@ entity_to 18@ colpoint_data_to 17@
                        then
                            0687: clear_actor 0@ task
                            078F: AS_actor 0@ climb 1
                            0006: TIMERA = 0
                        end
                    end
                end

                //     
                if and
                    0019:   TIMERB > 500
                    8118:   not actor 0@ dead
                    1@ == 203 // task stand_still
                then
                    if
                        0EE4: locate_char_distance_to_char 0@ char $PLAYER_ACTOR radius 50.0
                    then
                        0792: disembark_instantly_actor 0@
                        05E2: AS_actor 0@ kill_actor $PLAYER_ACTOR
                        0006: TIMERB = 0
                    else
                        if
                            timerb > 1000
                        then
                            0792: disembark_instantly_actor 0@
                            05E2: AS_actor 0@ kill_actor $PLAYER_ACTOR
                            0006: TIMERB = 0
                        end
                    end
                end

                //      
                if
                    Actor.Animation(0@) == "run_gang1" // cop run animation
                then
                    if
                        0EE4: locate_char_distance_to_char 0@ char $PLAYER_ACTOR radius 40.0
                    then
                        0393: actor 0@ perform_animation "run_gang1" at Speed_anim times_normal_rate // set speed from .ini
                    else
                        0087: 1@ = Speed_anim // (float)
                        1@ += 0.2
                        0393: actor 0@ perform_animation "run_gang1" at 1@ times_normal_rate // set speed from .ini
                        if
                            82CB:   not actor 0@ bounding_sphere_visible
                        then
                            1@ += 0.2
                            0393: actor 0@ perform_animation "run_gang1" at 1@ times_normal_rate // set speed from .ini
                        end
                    end
                end

            end
        end

end

:Buffer
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
